package com.xbao.service.impl;

import com.xbao.core.util.MyBeanUtil;
import com.xbao.dao.MySpreadMapper;
import com.xbao.model.MySpread;
import com.xbao.model.MySpreadExample;
import com.xbao.model.req.MySpreadReq;
import com.xbao.model.vo.MySpreadVo;
import com.xbao.service.MySpreadService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class MySpreadServiceImpl implements MySpreadService {
    @Resource
     private MySpreadMapper mapper;
    @Override
    public void addMySpread(MySpreadReq mySpread) {
        mapper.insert(mySpread);


    }

    @Override
    public void updateMySpread(MySpreadReq mySpreadReq) {
        mapper.updateByPrimaryKeySelective(mySpreadReq);

    }

    @Override
    public List<MySpreadVo> querySpread(MySpreadReq req) {
        MySpreadExample example= new MySpreadExample();
        MySpreadExample.Criteria criteria= example.createCriteria();
        List<MySpread> vs=mapper.selectByExample(example);
        List<MySpreadVo> vos= MyBeanUtil.copyList(vs,MySpreadVo.class);
        return vos;
    }

    @Override
    public void deleteSpread(MySpreadReq req) {
        mapper.deleteByPrimaryKey(req.getId());

    }
}
